/**
 *
 * $Id: RangingClient.i,v 1.4 2009-04-07 19:46:07 ttaipalu Exp $
 *
 * \file RangingClient.i
 * \brief Python bindings for following by Tapio Taipalus <tapio.taipalus@tkk.fi>
 * \file RangingClient.hpp
 * \brief MaCI - Ranging Interface Client module header
 * \author Antti Maula <antti.maula@tkk.fi>
 * 
 * \todo The GetDevicePosition and GetDeviceLimits functions are unimplemented.
 */
%module RangingClient

//for std::string
%include std_string.i
%include std_vector.i
%include "typemaps.i"
%include "../MaCIError.i"
%include "../common/timestamp.i"
%include "../MaCICtrl/MaCICtrlClient.i"

%{
#include "MaCI.hpp"
#include "thread.hpp"
#include "sync.hpp"
#include "RangingData.hpp"
#include "common/timestamp.hpp"
//#include "MaCICtrlServer.hpp"
#include <vector>
#include "RangingClient.hpp"
%}
%include "RangingTypes.i"
    

// Forward declaration for GIMIMessage
namespace gimi {
  class GIMIMessage;
}


namespace MaCI {

/*
	namespace Common {   
   		struct TTimestamp 
  		{
	      TTimestamp() 
	        : timestamp_s(0),
	          timestamp_us(0) {
	        	SetToCurrentTime();
      			}
	      TTimestamp(const unsigned int aS, const unsigned int aUS) 
	        : timestamp_s(aS),
	          timestamp_us(aUS) {}
	      TTimestamp(const gim::time &aGimTime)
	        : timestamp_s(aGimTime.getSeconds()),
	          timestamp_us(aGimTime.getUSeconds()) {}
	      void SetTime(const gim::time &aTime) {
	        timestamp_s = aTime.getSeconds();
	        timestamp_us = aTime.getUSeconds();
	      }
	      gim::time GetGimTime(void) const {
	        return gim::time((long int)timestamp_s, (long int)timestamp_us);
	      }
	      void SetToCurrentTime(void) {
	        long int s,us;
	        ownTime_GetTimeOfDay(&s,&us);
	        timestamp_s = s;
	        timestamp_us = us;
	      }
	      uint32_t timestamp_s;   ///< Seconds part of timestamp
	      uint32_t timestamp_us;  ///< Microseconds part of timestamp
		}; //struct TTimestamp
 	} //namespace Common
*/
 
  	namespace Ranging {
/*
	    struct TDistance 
	    {
	      TDistance(const float aAngle=0, const float aDistance=0)
		: angle(aAngle),
		  distance(aDistance) {}
	      float angle; ///< Angle of beam in radians
	      float distance; ///< Distance of beam in meters
	    };
	
	    
	
	    struct TDistanceHeader 
	    {
	      TDistanceHeader(const float aBeamWidth=0, const unsigned int aBeamCount=0)
		: beam_width(aBeamWidth),
		  beam_count(aBeamCount) {}
	      float beam_width;           ///< Width of beam in scan (rad)
	      uint32_t beam_count;    ///< Number of beams after header
	    };
*/
		typedef std::vector<TDistance> TDistanceArray;
	} //namespace Ranging

}  //namespace MaCI

namespace std{  
	%template(TDistanceArray) vector<MaCI::Ranging::TDistance>;
}

namespace MaCI {
  namespace Ranging {
    class CRangingClient : 	public MaCI::CMaCI, 
    						private gim::CSync,
                           	private gim::CThread
    {

    public:
      CRangingClient(gimi::GIMI *aGIMIPtr, const int aInterfaceMinor = 0);
      ~CRangingClient();
      bool GetDistanceArray(MaCI::Ranging::TDistanceArray &INOUT,
			    MaCI::Ranging::TDistanceHeader *INOUT, 
			    MaCI::Common::TTimestamp *INOUT,
			    int *INOUT, const int aTimeout_ms);
      bool GetDistanceArray(MaCI::Ranging::CRangingData &aData,
			    int *aSequence, const int aTimeout_ms);
      bool GetDeviceLimits(MaCI::Ranging::TDeviceInformationLimits &INOUT, const int aTimeout_ms = 1000, 
			   const bool aDirect = false);
      bool GetDevicePosition(MaCI::Ranging::TDeviceInformationPosition &INOUT, 
                             const int aTimeout_ms = 1000,
			     const bool aDirect = false);
      
      // Derived from MaCI
      MaCI::EMaCIError DoOpen(void);
      MaCI::EMaCIError DoClose(void);
      
      // Derived from MaCI::CMaCI
	    MaCI::EMaCIError Open();
	    MaCI::EMaCIError Close();    
	  //  void SetMaCICtrlServer(MaCI::MaCICtrl::CMaCICtrlServer *aMaCICtrlServer);
	    void SetDefaultTarget(const std::string &aDefaultTarget);
	    void SetStaticLinkDelay(const unsigned int aDelay_ms);
	    bool SetGroupName(const std::string &aGroupName);	      
		bool SetDefaultTarget(const MaCI::MaCICtrl::SMaCISL &aMaCISL, const unsigned int aTimeout_ms = 2000);

    };
  } // namespace Ranging
} //namespace MaCI